﻿
// <copyright file="TextReaderEnumerable.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The text reader enumerable.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Data
{
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;

    using SubhadraSolutions.Sharp.Utils.Validation;

    /// <summary>
    /// The text reader enumerable.
    /// </summary>
    public class TextReaderEnumerable : IEnumerable<string>
    {
        #region Fields

        /// <summary>
        /// The reader.
        /// </summary>
        private readonly TextReader _reader;

        #endregion Fields

        #region Constructors and Finalizers

        /// <summary>
        /// Initializes a new instance of the <see cref="TextReaderEnumerable"/> class.
        /// </summary>
        /// <param name="reader">
        /// The reader.
        /// </param>
        public TextReaderEnumerable(TextReader reader)
        {
            Guard.ArgumentNotNull(reader, "reader");
            this._reader = reader;
        }

        #endregion Constructors and Finalizers

        #region Public Methods and Operators

        /// <summary>
        /// The get enumerator.
        /// </summary>
        /// <returns>
        /// The <see cref="IEnumerator"/>.
        /// </returns>
        public IEnumerator<string> GetEnumerator()
        {
            return new TextReaderEnumerator(this._reader);
        }

        #endregion Public Methods and Operators

        #region Explicit Interface Methods

        /// <summary>
        /// The get enumerator.
        /// </summary>
        /// <returns>
        /// The <see cref="IEnumerator"/>.
        /// </returns>
        IEnumerator IEnumerable.GetEnumerator()
        {
            return new TextReaderEnumerator(this._reader);
        }

        #endregion Explicit Interface Methods
    }
}